package com.example.jdai.jdai.rest;

import android.util.Log;

import com.example.jdai.jdai.MyApplication;
import com.example.jdai.jdai.config.Config;
import com.example.jdai.jdai.rest.bean.LoginBean;

import java.io.IOException;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by hellopyj on 2017/1/10.
 */

public class RestApi {
    //验证码
    public interface CodeService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("pub/sms/send")
        Observable<GetData<String>> getCode(@Body RequestBody body);
    }
    //更新
    public interface UpdateService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/update/get")
        Observable<Response<GetData<Map>>> getCode(@Body RequestBody body);
    }
    //获取信息
    public interface GetInfoService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/user/info")
        Observable<Response<GetData<LoginBean>>> getInfo(@Body RequestBody body);
    }
    //登入
    public interface LoginService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/user/login")
        Observable<GetData<LoginBean>> login(@Body RequestBody body);
    }
    //添加联系人
    public interface AddService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/contact/add")
        Observable<GetData<Integer>> add(@Body RequestBody body);
    }
    //完善个人信息
    public interface InfoService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/person")
        Observable<GetData<Integer>> update(@Body RequestBody body);
    }
    //完善通讯
    public interface ConnectService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/contact")
        Observable<GetData<Integer>> update(@Body RequestBody body);
    }
    //完善电话
    public interface PhoneService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/tel")
        Observable<GetData<Integer>> update(@Body RequestBody body);
    }
    //七牛云
    public interface TokenService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("pub/qiniu/token")
        Observable<GetData<String>> getToken(@Body RequestBody body);
    }
    //提交
    public interface OkService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/commit")
        Observable<GetData<Integer>> commit(@Body RequestBody body);
    }
    //提交
    public interface ZiMaService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/zmxy")
        Observable<GetData<Integer>> commit(@Body RequestBody body);
    }
    //支付宝
    public interface ZfbService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/zfb")
        Observable<GetData<Integer>> commit(@Body RequestBody body);
    }
    //京东
    public interface JdService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/jd")
        Observable<GetData<Integer>> commit(@Body RequestBody body);
    }
    //征信
    public interface ZxService {
        @Headers({"Content-Type: application/json","Accept: application/json"})
        @POST("user/verify/zx")
        Observable<GetData<Integer>> commit(@Body RequestBody body);
    }
    //转化为原数据
    public static  RequestBody getBody(SendCode send)
    {
        String sendStr= null;
        sendStr = MyApplication.gson.toJson(send);
        if (Config.ISDEBUG)
        Log.v("json", sendStr );
        return RequestBody.create(MediaType.parse("application/json; charset=utf-8"),sendStr);
    }

}
